package com.woniu.zsd.permission.mapper;

import com.woniu.zsd.permission.entity.RolesResource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-03-27
 */
public interface RolesResourceMapper extends BaseMapper<RolesResource> {
    List<Map<String, Object>> selectRolesResourceWithDetails();

    @Update("update roles_resource set roles_id=#{rolesId},resource_id=#{resourceId} where id=#{id}")
    int updateRolesResource(@Param("id") Integer id,@Param("rolesId") Integer rolesId, @Param("resourceId") Integer resourceId);

    @Select("select * from roles_resource where roles_resource.roles_id=#{rolesId}")
    List<RolesResource> selRolesResource(Integer id);

    @Delete("delete from roles_resource where id=#{id}")
    int deleteRolesResource(Integer id);

    @Insert("insert into roles_resource(roles_id,resource_id) values(#{rolesId},#{resourceId})")
    int addRolesResource(@Param("rolesId") Integer rolesId,@Param("resourceId") Integer resourceId);
}
